﻿#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;
using System.Runtime.Serialization;

#endregion

namespace ESF.SFT.Entities
{
	[Table]
	[Serializable]
	[DataContract]
	public class FileReceiveLog
	{
		[Column (IsDbGenerated=true, IsPrimaryKey=true)]
		[DataMember]
		public long? ID { set; get; }

		[Column]
		[DataMember]
		public string FileName { set; get; }


		public string Name { get { return System.IO.Path.GetFileName (FileName); } }


		[Column]
		[DataMember]
		public DateTime? UploadDateTime { set; get; }
		
		[Column]
		[DataMember]
		public string UploadUserAlias { set; get; } 

		[Column]
		[DataMember]
		public long? LengthBytes { set; get; }


		[Column]
		[DataMember]
		public string UserHostAddress { set; get; }

		[Column]
		[DataMember]
		public string ServerHostName { set; get; }


		[Column]
		[DataMember]
		public string ServerHostAddress { set; get; }


		[DataMember]
		public DateTime? ProcessedDateTime { set; get; }


		[DataMember]
		public int? TryCount { set; get; }

		[DataMember]
		public string MD5Hash { set; get; }


		[DataMember]
		public string ShortIdentificator { set; get; }


		[DataMember]
		public bool IsDigitalSignInvalid { set; get; }


		[DataMember]
		public string DigitalSignInvalidDetail { set; get; }
				

		[DataMember]
		public string IdentificationNumber { set; get; }

		[DataMember]
		public string IdentificationTypeCode { set; get; }

		[DataMember]
		public string GUID { set; get; }


		public string Status
		{
			get
			{
				if (((TimeSpan) (DateTime.Now - UploadDateTime.Value)).TotalMinutes <= 5)
				{
					return "NEW";
				}

				return "PEN";
			}
		}



		#region Filtros

		[DataMember]
		public DateTime? filStartUploadDateTime { set; get; }
		
		[DataMember]
		public DateTime? filEndUploadDateTime { set; get; }

		#endregion
	}
}
